/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       mine.h

	$Header: /game/mine.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef MINE_H_INCLUDED
#define MINE_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "material_array.h"
#include "ownable_garrisonable_adv_object.h"

enum	t_material;
class	t_material_array;
enum	t_two_way_facing;

// --------------------------------------------------------------
// mine which produces materials
// --------------------------------------------------------------
class t_mine : public t_ownable_garrisonable_adv_object
{
public:
	t_mine( t_material material, t_two_way_facing facing);
	t_mine( std::string const& source );

	virtual void         activate_trigger( t_army* army, t_adv_map_point const& point, 
		                                   t_direction direction, t_adventure_frame* frame );
	virtual float		 ai_value( t_adventure_ai const& ai, t_creature_array const& army, int move_cost ) const;	
	virtual float		 ai_activation_value_drop( t_creature_array const& army ) const;
	virtual void         destroy();
    virtual t_bitmap_cursor const & get_cursor( t_adventure_map_window const& window,
		                                        t_army const*				  army ) const;
	t_material          get_material() const;
	int                 get_production() const;
	int					get_production( t_material type ) const;
	virtual int			get_version() const;
	
	virtual void         initialize( t_adventure_map& map );
	virtual void	     left_double_click( t_mouse_event const& event, 
							                t_adventure_frame* adventure_frame );
	virtual void					on_combat_end( t_army* attacker, t_combat_result result,
												   t_creature_array* losses, 
												   t_adventure_frame* frame );
	virtual void		 place( t_adventure_map& map, t_adv_map_point const& point );
	virtual void         process_new_day();
	virtual bool		read( std::streambuf&						stream, 
							  t_qualified_adv_object_type const&	type,
							  int									version );
	virtual void         read_postplacement( t_adventure_map& map );
	virtual void		 right_click( t_mouse_event const& event,
								      t_adventure_frame* adventure_frame );
	virtual void         set_owner( int player_number );
private:
	void visit( t_army* army, t_adventure_frame* frame, bool battle );
	std::string         m_creature_name_text;
};

inline t_material t_mine::get_material() const
{
	return t_material( get_major_subtype() );
}

// -------------------------------------------------------
// undeveloped mine as it appears on the adventure map
// -------------------------------------------------------
class t_adv_vein : public t_stationary_adventure_object
{
public:
	t_adv_vein( std::string const& source );
	virtual void        activate_trigger( t_army* army, t_adv_map_point const& point, 
		                                  t_direction direction, t_adventure_frame* frame );
	virtual float		ai_value( t_adventure_ai const& ai, t_creature_array const& army, int move_cost ) const;	
	virtual void		place( t_adventure_map& map, t_adv_map_point const& point );

private:
	t_material			m_material;
	t_material_array	m_cost;
};

int get_mine_production(int material);

#endif // MINE_H_INCLUDED
